<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="content">
		<div class='full-center-content-scroll-noheader'>
			<div class="nav-tabs-custom">
				<ul class="nav nav-tabs pull-left ">
					<li class="active"><a href="#aCLineSegmentDiv"
						data-toggle="tab">交流线路基本信息</a></li>
					<li><a href="#lineparamDiv" id="deviceRelateTab"
						data-toggle="tab">交流线路TA</a></li>
					<li><a href="#ratioDiv" data-toggle="tab">变比字典表</a></li>
				</ul>
				<div class="tab-content no-padding">
					<div class="chart tab-pane active" id="aCLineSegmentDiv"
						style="position: relative">
						<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
							<p:commandButton value="是" type="button"
								styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
							<p:commandButton value="否" type="button"
								styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
						</p:confirmDialog>
						<p:growl id="msgs" showDetail="true" />
						<h:form id="aClineSegmentForm">
							<div class="box box-solid with-border">
								<div class="box-header">
									<p:outputLabel value="选择要查看的电压等级：" />
									<h:selectOneMenu value="#{aclinesegmentController.selectVoltage}"
										style="width:130px;margin-right:20px;height:30px">
										<p:ajax event="change" listener="#{aclinesegmentController.getACLineSegmentByVoltagelevel}" update="aClineSegmentDataTable"/>
										<f:selectItem itemLabel="电压等级" itemValue="0" />
										<f:selectItems value="#{aclinesegmentController.voltages}" />
									</h:selectOneMenu>
									<p:outputLabel value="线路名称：" />
									<p:inputText
										value="#{aclinesegmentController.aCLineSegmentName}" />
									<p:commandButton value="查询" style="margin-left:10px"
										update="aClineSegmentDataTable"
										actionListener="#{aclinesegmentController.searchACLineSegments}"
										icon="ui-icon-search" />
									<p:commandButton value="未匹配线路"
										actionListener="#{aclinesegmentController.getNotMatch}"
										update="msgs aClineSegmentForm" />
									<p:commandButton value="已匹配线路"
										actionListener="#{aclinesegmentController.getMatched}"
										update="msgs aClineSegmentForm" />
								</div>
							</div>
							<p:toolbar id="aclineToolBar">
								<f:facet name="left">
									<p:commandButton value="上传"
									rendered="#{s:hasPermission(session,'xtsz_dwmx_xlmx_jlxljbxx_sc')}"
										onclick="PF('aClineSegmentDialog').show()" />
									<p:commandButton value="新建" icon="ui-icon-document"
									rendered="#{s:hasPermission(session,'xtsz_dwmx_xlmx_jlxljbxx_xj')}"
										actionListener="#{aclinesegmentController.preACLineSegment}"
										oncomplete="PF('createDlg').show()" update="createDlg" />
									<p:commandButton value="编辑" icon="ui-icon-document"
										disabled="#{aclinesegmentController.selectACLineSegment.id ==null}"
										rendered="#{s:hasPermission(session,'xtsz_dwmx_xlmx_jlxljbxx_bj')}"
										actionListener="#{aclinesegmentController.editACLineSegment}"
										oncomplete="PF('createDlg').show()" update="createDlg" />
									<p:growl id="msgs" showDetail="true" />
									<p:commandButton value="删除" icon="ui-icon-trash"
										disabled="#{aclinesegmentController.selectACLineSegment.id ==null}"
										rendered="#{s:hasPermission(session,'xtsz_dwmx_xlmx_jlxljbxx_shancu')}"
										actionListener="#{aclinesegmentController.deleteACLineSegment}"
										update="msgs aClineSegmentForm">
										<p:confirm header="提示" message="确定删除该记录吗?"
											icon="ui-icon-alert" />
									</p:commandButton>
								</f:facet>
							</p:toolbar>
							
							<p:dataTable style="text-align:center" value="#{aclinesegmentController.aCLineSegments}" 
								id="aClineSegmentDataTable" var="aClineSegment" emptyMessage="无记录" rows="20" paginator="true"
								rowKey="#{aClineSegment.id}" rowIndexVar="ite"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} 
				                   {RowsPerPageDropdown}" paginatorPosition="bottom" rowsPerPageTemplate="20,50,100">
								<p:ajax event="rowSelectRadio" listener="#{aclinesegmentController.onRowSelect}" update=":aClineSegmentForm:aclineToolBar" />
								<f:facet name="{Customization}">
									<!-- <p:outputLabel value="总计：#{aclinesegmentController.aCLineSegments.size()} 条记录" style="margin-right:20px;"></p:outputLabel> -->
									<p:outputLabel id="voltageInfo" value="#{aclinesegmentController.voltageInfo}" />
								</f:facet>
								<p:column selectionMode="single" style="width:60px"/>
								<p:column headerText="序号 " style="width:60px">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="线路名">
									<p:outputLabel value="#{aClineSegment.name}" />
								</p:column>
								<p:column headerText="电压等级(kV)">
									<p:outputLabel value="#{aClineSegment.standVoltagelevel}" />
								</p:column>
								<p:column headerText="线路长度">
									<p:outputLabel value="#{aClineSegment.length}" />
								</p:column>
								<p:column headerText="r0">
									<p:outputLabel value="#{aClineSegment.r0}" />
								</p:column>
								<p:column headerText="x0">
									<p:outputLabel value="#{aClineSegment.x0}" />
								</p:column>
								<p:column headerText="r1">
									<p:outputLabel value="#{aClineSegment.r1}" />
								</p:column>
								<p:column headerText="x1">
									<p:outputLabel value="#{aClineSegment.x1}" />
								</p:column>
							</p:dataTable>
							<p:dialog widgetVar="createDlg" header="保护动作指标" modal="true"
								id="createDlg" width="350" height="300">
								<p:toolbar>
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{aclinesegmentController.saveACLineSegment}"
											update="msgs aClineSegmentForm" oncomplete="PF('createDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="线路名" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.name}" />
										<h:outputText value="线路长度" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.length}" />
										<h:outputText value="r0" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.r0}" />
										<h:outputText value="x0" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.x0}" />
										<h:outputText value="r1" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.r1}" />
										<h:outputText value="x1" />
										<p:inputText
											value="#{aclinesegmentController.aCLineSegment.x1}" />
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
						</h:form>
					</div>
					<h:form id="dialog">
						<p:dialog widgetVar="aClineSegmentDialog" modal="true"
							id="aClineSegmentDialog" header="文件格式要求" width="450" height="300">
							<h4 style="color: red">请使用第一个sheet页上传，列名依次为：线路 ，线路长度 ， R1 ，
								X1 ， R0 ， X0 。</h4>
							<p:fileUpload cancelLabel="取消"
								fileUploadListener="#{aclinesegmentController.handleWaveFileUpload}"
								onstart="PF('statusDialog').show()" uploadLabel="上传"
								oncomplete="PF('statusDialog').hide() , PF('fileUpload').hide() , PF('logDialog').show()"
								update="aClineSegmentForm:aClineSegmentDataTable  msgs logDialog"
								label="文件" />
						</p:dialog>

						<p:dialog widgetVar="lineparamDialog" modal="true"
							id="lineparamDialog" header="文件格式要求" width="450" height="300">
							<h4 style="color: red">请使用第一个sheet页上传，列名依次为：线路 ， 母线， 厂站，
								正常TA ， TV。</h4>
							<p:fileUpload cancelLabel="取消"
								fileUploadListener="#{aclinesegmentController.handleWaveFileUpload}"
								onstart="PF('statusDialog').show()" uploadLabel="上传"
								oncomplete="PF('statusDialog').hide() , PF('fileUpload').hide() , PF('logDialog').show()"
								update=" lineparam:lineparamsDataTable msgs logDialog ratioForm"
								label="文件" />
						</p:dialog>

						<p:dialog widgetVar="fileUpload" modal="true" id="fileUpload"
							width="400" height="200">
							<p:toolbar>
								<f:facet name="left">
									<p:fileUpload cancelLabel="取消"
										fileUploadListener="#{aclinesegmentController.handleWaveFileUpload}"
										onstart="PF('statusDialog').show()" uploadLabel="上传"
										oncomplete="PF('statusDialog').hide() , PF('fileUpload').hide() , PF('logDialog').show()"
										update="aClineSegmentForm:aClineSegmentDataTable lineparam:lineparamsDataTable msgs logDialog"
										label="文件" />
								</f:facet>
							</p:toolbar>
						</p:dialog>
						<p:dialog widgetVar="logDialog" modal="true" id="logDialog"
							width="900" height="700" header="异常信息">
							<p:inputTextarea value="#{aclinesegmentController.errLog}"
								readonly="true" style="width:100%">

							</p:inputTextarea>
						</p:dialog>
						<p:dialog widgetVar="statusDialog" modal="true" draggable="false"
							closable="false" resizable="false" showHeader="false">
							<img src="#{request.contextPath}/resources/img/ajaxloadingbar.gif" />
						</p:dialog>
					</h:form>
					<div class="chart tab-pane" id="lineparamDiv" style="position: relative">
					<h:form id="lineparam">
						<div class="box box-solid with-border">
							<div class="box-header">
								<p:outputLabel value="选择电压等级：" />
								<h:selectOneMenu  id="selectVoltage"   value="#{aclinesegmentController.selectVoltage}"
									style="width:130px;margin-right:20px;height:30px">
									<p:ajax event="change" listener="#{aclinesegmentController.getlineparamsByVoltagelevel}" update="lineparamsDataTable" />
									<f:selectItem itemLabel="电压等级" itemValue="0" />
									<f:selectItems value="#{aclinesegmentController.voltages}" />
								</h:selectOneMenu>
								<p:outputLabel value="线路名称：" id="lineparamName"  style="margin-left:10px"/>
								<p:inputText value="#{aclinesegmentController.lineparamName}" />
								<p:outputLabel value="母线："   id="lineparamBus" style="margin-left:10px" />
								<p:inputText value="#{aclinesegmentController.lineparamBus}" />
								<p:outputLabel value="所在厂站："  id="lineparamSubStation" style="margin-left:5px"/>
								<p:inputText value="#{aclinesegmentController.lineparamSubStation}" />
								<p:commandButton value="未匹配线路" actionListener="#{aclinesegmentController.lineparamsNotMatched}"
									update="lineparamsDataTable" style="margin-left:10px"/>
								<p:commandButton value="搜索" style="margin-left:10px"
									update="lineparamsDataTable" icon="ui-icon-search" 
									actionListener="#{aclinesegmentController.serchLineparams}" />
								<p:commandButton icon="ui-icon-refresh" actionListener="#{aclinesegmentController.init()}" 
									update="lineparam  selectVoltage lineparamName lineparamBus  lineparamSubStation" value="重置" style="margin-left:5px;"/>
							</div>
						</div>
						<p:toolbar>
							<f:facet name="left">
								<p:commandButton value="上传"
									rendered="#{s:hasPermission(session,'xtsz_dwmx_xlmx_jlxlTA_sc')}"
									actionListener="#{aclinesegmentController.fileUpload}"
									onclick="PF('lineparamDialog').show()" />
							</f:facet>
						</p:toolbar>
						
						<p:dataTable value="#{aclinesegmentController.lineparams}" rowIndexVar="ite"
							var="lineparams" style="text-align:center" emptyMessage="无记录"
							rows="20" paginator="true" lazy="true" id="lineparamsDataTable"
							paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} 
		                    {RowsPerPageDropdown}" paginatorPosition="bottom" rowsPerPageTemplate="20,50,100">
		                    <p:column headerText="序号 " style="width:60px">
								<h:outputText value="#{ite+1}" />
							</p:column>
							<f:facet name="{Customization}">
								<p:outputLabel value="#{aclinesegmentController.lineparamInfo}" id="lineparamInfo" />
								<!-- <p:outputLabel value="总计：#{aclinesegmentController.lineparams.size()} 条记录" style="margin-right:20px;"></p:outputLabel> -->
							</f:facet>
							<p:column headerText="线路名">
								<p:outputLabel value="#{lineparams.name}" />
							</p:column>
							<p:column headerText="母线">
								<p:outputLabel value="#{lineparams.bus}" />
							</p:column>
							<p:column headerText="所在厂站">
								<p:outputLabel value="#{lineparams.substation}" />
							</p:column>
							<p:column headerText="CT变比一次侧">
								<p:outputLabel value="#{lineparams.TA_P}" />
							</p:column>
							<p:column headerText="CT变比二次侧">
								<p:outputLabel value="#{lineparams.TA_S}" />
							</p:column>
							<p:column headerText="PT变比一次侧">
								<p:outputLabel value="#{lineparams.TV_P}" />
							</p:column>
							<p:column headerText="PT变比二次侧">
								<p:outputLabel value="#{lineparams.TV_S}" />
							</p:column>
						</p:dataTable>
						</h:form>
					</div>

					<div class="chart tab-pane" id="ratioDiv" style="position: relative">
						<h:form id="ratioForm">
							<p:dataTable value="#{aclinesegmentController.waveRatios}"
								var="waveRatio" style="text-align:center" emptyMessage="无记录" rows="20" paginator="true" lazy="true" id="waveRatioDT"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} 
                                {RowsPerPageDropdown}" paginatorPosition="bottom" rowsPerPageTemplate="20,50,100">
								<f:facet name="{Customization}">
									<p:outputLabel value="总计：#{aclinesegmentController.waveRatios.size()} 条记录" style="margin-right:20px;"></p:outputLabel>
								</f:facet>
								<p:column headerText="type">
									<p:outputLabel value="#{waveRatio.rtype}" />
								</p:column>

								<p:column headerText="变比">
									<p:outputLabel value="#{waveRatio.ps}" />
								</p:column>
							</p:dataTable>
						</h:form>
					</div>
				</div>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script>
			$(this).keydown( function(e) {
			    var key = window.event?e.keyCode:e.which;
			    if(key.toString() == "13"){
			        return false;
			    }
			});
		</script>
		<script>
			function onSelectDivClick() {
				var div = $('#selectDiv');
				if (div.hasClass('in')) {
					div.collapse('hide');
					$('#selectButtonIcon').removeClass("fa fa-caret-up");
					$('#selectButtonIcon').addClass("fa fa-caret-down");
				} else {
					div.collapse('show');
					$('#selectButtonIcon').removeClass("fa fa-caret-down");
					$('#selectButtonIcon').addClass("fa fa-caret-up");
				}
			}
		</script>
	</ui:define>
</ui:composition>